package conf

import (
	"os"
	"strings"

	"github.com/sirupsen/logrus"
)

const (
	logFileName = "stream.log"
)

var (
	Log       *logrus.Logger
	IsTesting bool
	// Log       *logrus.Logger
	// logFile   *os.File
	//logFile = logger.LogFile
)

func init() {
	InitLogger()
}

func InitLogger() {

	Log = logrus.New()
	//Log.Warnf("Log.Out1: %v", Log.Out)
	filenameHook := NewHook()
	filenameHook.Field = "file"
	Log.AddHook(filenameHook)
	Log.SetFormatter(&logrus.TextFormatter{
		DisableColors: true,
		FullTimestamp: true,
	})
	// Log.SetLevel( WarnLevel)
	Log.Warnf("GetLevel: %v", Log.GetLevel())
	Log.Debugf("init with args %s", os.Args)
	for _, arg := range os.Args {
		if strings.HasPrefix(arg, "-test.") {
			IsTesting = true
			break
		}
	}
}
